﻿/*-------------------------------------------------------------------------
* 命名空间: SiliconSelect.Converter/RoleIndexConverter
* 类       名: RoleIndexConverter
* 功      能:  TD
* 时      间:  2023/8/8 12:01:47
* 版      本:  V1.0
* 作      者:  Fioman
* 格      言:  Talk is cheap,show me the code ^_^
*-------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace SiliconSelect.Converter
{
    public class RoleIndexConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string temp)
            {
                if (temp == "操作员")
                {
                    return 0;
                }
                else if (temp == "管理员")
                {
                    return 1;
                }
                else
                {
                    return 2;
                }
            }
            return 0;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int index = (int)value;
            if (index == 0)
            {
                return "操作员";
            }
            else if (index == 1)
            {
                return "管理员";
            }
            else
            {
                return "工程师";
            }
        }
    }
}
